package com.sgzn.sgpay.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by linliangfang 13580393408
 * DATETIME:2018/5/26 11:45
 * Description:
 */
public enum EnumWithdrawStat {
    S0D("S0D", "已受理"),
    S0S("S0S", "成功"),
    S0F("S0F", "失败");

    @Getter
    private String stateCode;
    @Getter
    private String stateDesc;

    //构造函数
    EnumWithdrawStat(String stateCode, String stateDesc) {
        this.stateCode = stateCode;
        this.stateDesc = stateDesc;
    }

    private static final Map<String, String> map = new HashMap<String, String>();

    static{
        for(EnumWithdrawStat single : EnumWithdrawStat.values()){
            map.put(single.stateCode, single.stateDesc);
        }
    }

    /**
     * 根据编码码获取类型
     * @param stateCode
     * @return
     */
    public static String getDescByCode(String stateCode) {
        if(isContain(stateCode)){
            return map.get(stateCode);
        }
        return stateCode+"未定义";
    }


//    /**
//     * 根据描述获取编码
//     * @param stateDesc
//     * @return
//     */
//    public static String getCodeByDesc(String stateDesc) {
//        if(isContain(stateCode)){
//            return map.get(stateCode);
//        }
//        return stateCode+"未定义";
//    }

    public static boolean isContain(String stateCode){
        if(map.containsKey(stateCode)){
            return true;
        }
        return false;
    }

}
